<template>
    <div>
        <button @click="show = !show">showBox</button>
        <Transition
        appear
        mode="out-in"
        name="box">
            <div class="box" v-if="show">
                <p><i>这里是小M，现在是动画</i></p>
            </div>
        </Transition>
    </div>
</template>

<script setup>
import { ref } from "vue";

const show = ref(false)

</script>

<style lang="scss" scoped>
* {
    margin: 0;
    padding: 0;
}

button {
    width: 200px;
    border-radius: 8px;
    border: 1px solid green;
    padding: 4px;
    margin: 4px;
}

button:hover {
    background-color: green;
    color: white;
}

.box {
    width: 200px;
    height: 200px;
    border-radius: 4px;
    margin:10px 4px;
    padding: 10px;
    background-color: rgb(226, 226, 186);

    &-enter-active {
        animation:bounceInLeft;
        animation-duration: 0.8s;
    }

    &-leave-active {
        animation:bounceOutLeft;
        animation-duration: 0.8s;
    }

    @keyframes box-start {
        from{
            opacity: 0;
            transform:translateX(0px);
        }
        to{
            opacity: 1;
        }
    }
    @keyframes box-end {
        to{
            opacity: 0;
            transform: translateX(-100%);
        }
    }

}</style>